<%@ page import="entity.Operator" %><%--
  Created by IntelliJ IDEA.
  User: 59565
  Date: 2019/6/25
  Time: 3:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改密码</title>
    <%
        Operator operator = (Operator) request.getSession().getAttribute("loginOperator");
    %>
</head>
<body background="../image/happySun.jpg" style="opacity: 0.6">
<div id="content">
    <form action="PasswordChangeServlet" method="post" style=" text-align: center;position: absolute;top:40%;left:40%">
        <input type="text" style="display: none;" id="operatorId" name="operatorId" value="<%=operator.getOperatorID()%>">
        <input type="text" style="display: none;" id="password" name="password" value="<%=operator.getPassword()%>">
        请输入原密码：<input type="password" id="oldPassword" name="oldPassword">

        <br><br>

        请输入新密码：<input type="password" id="newPassword" name="newPassword">
        <br><br>

        请再次输入新密码：<input type="password" id="newPassword2" name="newPassword2">
        <br><br>

        <p style="color: red;" id="wrongTip"></p>
        <input onclick=" return checkPassword()" type="submit" value="提交"
               style= "background-color:transparent;border:0;font-size: 16px">
        <input type="button" onclick="window.location='index.jsp'"
               style= "background-color:transparent;border:0;font-size: 16px" value="取消">
    </form>
</div>

</body>
</html>
<script>
    function checkPassword() {
        if(password.value != oldPassword.value){
            document.getElementById("wrongTip").innerText = "密码错误";
            return false;
        }else if(newPassword.value == ""){
            document.getElementById("wrongTip").innerText = "密码不能为空";
            return false;
        }else if(newPassword.value != newPassword2.value){
            document.getElementById("wrongTip").innerText = "两次密码不一致";
            return false;
        }
        alert("修改成功，请重新登录");
        return true;
    }
</script>